package com.ling.pl.core.context;

import com.ling.pl.core.commons.utils.SpringUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ContextUitls {
    static ContextSecurity contextSecurity;

    public static ContextSecurity getContextSecurity() {
        if (contextSecurity == null) {
            contextSecurity = SpringUtil.getBean(ContextSecurity.class);
        }
        return contextSecurity;
    }

    /**
     * token部分 模拟登录
     */
    public static void login(Object userInfo) {
        getContextSecurity().login(userInfo);
    }

    /**
     * filter 用于容器的filter调用
     *
     * @param request
     * @param response
     */
    public static void filter(HttpServletRequest request, HttpServletResponse response) {
        getContextSecurity().filter(request, response);
    }

    /**
     * token部分 模拟登出
     */
    public static void logout(HttpServletRequest request, HttpServletResponse response) {
        getContextSecurity().logout(request, response);
    }
}
